#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

STOP=90

restart() {
	:
}

stop() {
	if [ ! -f /rom/rom/note ]; then
		sync /overlay
		umount /overlay
		sync /ext_overlay
		umount /ext_overlay
	else
		# pivot
		mount --move /dev /rom/dev
		mount --move /tmp /rom/tmp
		mount --move /sys /rom/sys
		mount --move /ext_overlay /rom/ext_overlay
		mount --move /overlay /rom/overlay
		mount --move /proc /rom/proc
		if pivot_root /rom /rom/mnt; then
			sync
			/usr/bin/umount -R -d /mnt
			sync /mnt
			umount /mnt
			sync /overlay
			umount /overlay
			sync /ext_overlay
			umount /ext_overlay
		else
			mount --move /rom/proc /proc
			mount --move /rom/dev /dev
			sync
		fi
	fi
	sync
	echo 2 > /proc/sys/vm/drop_caches
	/bin/umount -a -d -r
}
